/*
 * Created on 28/mag/07
 *
 * To change the template for this generated file go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
package it.unibo.deis.lia.mmhc.test;

import java.net.*;

//import java.io.*;

public class MMHCTestServerReconfiguration extends Thread {

	public static void main(String argv[]) throws Exception {
		MMHCTestServerReconfiguration macTest = new MMHCTestServerReconfiguration();
		macTest.start();
	}

	public void run() {
		int count = 0;
		try {
			// ServerSocket server=new ServerSocket(3333);
			DatagramSocket ds = new DatagramSocket(3333);

			System.out.println("MACTestServer waiting for...");
			byte[] buffer = new byte[1024];
			DatagramPacket dp = new DatagramPacket(buffer, buffer.length);
			while (true) {
				ds.receive(dp);
				byte[] data = dp.getData();
				System.out.println(count + " MACTestServer received "
						+ new String(data, 0, dp.getLength()));
				System.out.println(count + " MACTestServer from "
						+ dp.getSocketAddress() + " "
						+ System.currentTimeMillis());
				System.out.println();

				/*
				 * Socket s=server.accept(); InputStream is=s.getInputStream();
				 * try{ int received; while(true){ received=is.read();
				 * System.out
				 * .println(numSocket+" MACTestServer received "+received); } }
				 * catch(Exception e){ e.printStackTrace(); }
				 */
				count++;
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
